package second.dp;

public class Solution46 {
    public int maxSubArray(int[] nums) {
        int max = Integer.MIN_VALUE;
        int cur = 0;
        for (int i = 0; i < nums.length; i++) {
            if (cur > 0) cur += nums[i];
            else cur = nums[i];
            max = Math.max(max, cur);
        }
        return max;
    }
}
